#include "stdafx.h"

#include "Error.h"

using namespace std;

sError::sError()
{
	ErrorText = "";
	Line = -1;
	eType = ERROR_NONE;
}

CError::CError()
{
}

CError::CError(sError err)
{
	m_ErrorList[err.File].push_back(err);
}

CError::CError(CString ErrorText, int line, ErrorType et, CString eFile)
{
	sError tmp;
	tmp.eType = et;
	tmp.ErrorText = ErrorText;
	tmp.File = eFile;
	tmp.Line = line;
	m_ErrorList[eFile].push_back(tmp);
}

CError::~CError()
{
}

void CError::NewError(CString ErrorText, int line, CString eFile, ErrorType et)
{
	sError tmp;
	tmp.ErrorText = ErrorText;
	tmp.Line = line;
	tmp.eType = et;
	
	m_ErrorList[eFile].push_back(tmp);
}

list<sError> CError::getErrorsByFile(CString fileName)
{
	return m_ErrorList[fileName];
}

list<sError> CError::getErrorsByType(ErrorType eType)
{
	list<sError> rtn;
	sError tmp;
	for(map<CString,list<sError>>::iterator itr = m_ErrorList.begin();
		itr != m_ErrorList.end(); itr++)
	{
		for(list<sError>::iterator itr2 = m_ErrorList[itr->first].begin();
			itr2 != m_ErrorList[itr->first].end(); itr2++)
		{
			tmp = *itr2;
			if (tmp.eType == eType)
			{
				rtn.push_back(tmp);
			}
		}
	}
	return rtn;
}